<?php

/*
 * Copyright (C) Error: on line 4, column 33 in Templates/Licenses/license-gpl30.txt
  The string doesn't match the expected date/time format. The string to parse was: "7.7.2014". The expected format was: "MMM d, yyyy". CZDP01
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

namespace system;

use Exception;

if (!defined('SECURE') or SECURE <> 'XLKDZJRKWOSLCMG') : throw new Exception('Nemáte oprávnění přistupovat k souboru!');
endif;

/**
 * Description of router
 *
 * @author CZDP01
 */

final class router {

    private $geturl = array();

    public function __construct() {
        $urlarray = explode('/', trim(strtolower(preg_replace('/<[^<]+?(.*)>/i', '', filter_input(INPUT_GET, 'url', FILTER_SANITIZE_URL))), DS));
        if (empty($urlarray[0])) : $urlarray[0] = 'home';
        endif;
        if (empty($urlarray[1])) : $urlarray[1] = 'home';
        endif;
        if (empty($urlarray[2])) : $urlarray[2] = 'home';
        endif;
        $urlarray[0] = strtolower($urlarray[0]);
        $urlarray[1] = strtolower($urlarray[1]);
        $urlarray[2] = strtolower($urlarray[2]);
        $this->geturl = array_filter($urlarray);
    }

    public function getroute() {
        return $this->geturl;
    }
}